<!-- 客服兼容 -->
<template>
	<view class="chat-template-box">
		<Chat @showMore="showMore" :useNum="useNum"></Chat>
		<!-- <u-action-sheet @select="selectItem" @close="showMask = false" :actions="list" :title="title" :show="showMask">
		</u-action-sheet> -->
	</view>
</template>

<script>
	import {
		getToken,
		setToken
	} from '@/utils/token.js'
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from "vuex";
	import Chat from "./shopro/index.vue";
	export default {
		components: {
			Chat
		},
		data() {
			return {
				title: '更多操作',
				list: [],
				showMask: false,
				useNum:''
			};
		},
		onLoad: function(option) {
			this.useNum = option.useNum
		},
		beforeDestroy: function() {
		  this.$store.commit('setChatItem', {})
		},
		computed: {
			...mapGetters(['chatItem', 'useState']),
		},
		watch:{
			// #ifdef MP-WEIXIN
			showMask:function(){
				if(this.showMask){
					if (this.useState.inMyList) {
						this.list = [{
								name: '移出黑名单',
								id: 3
							},
							{
								name: '删除好友',
								color: '#ff3434',
								id: 2
							}
						]
					} else {
						this.list = [{
								name: '加入黑名单',
								id: 1
							},
							{
								name: '删除好友',
								color: '#ff3434',
								id: 2
							}
						]
					}
				}
			}
			// #endif
		},
		
		onNavigationBarButtonTap(e) {
			// #ifndef MP-WEIXIN
			if (this.useState.inMyList) {
				this.list = [{
						name: '移出黑名单',
						id: 3
					},
					{
						name: '删除好友',
						color: '#ff3434',
						id: 2
					}
				]
			} else {
				this.list = [{
						name: '加入黑名单',
						id: 1
					},
					{
						name: '删除好友',
						color: '#ff3434',
						id: 2
					}
				]
			}
			
			this.showMask = true
			// #endif
			
		},
		methods: {
			showMore(data){
				this.showMask = data
			},
			selectItem(e) {
				if (e.id == 1) { //加入黑名单
					this.$store.dispatch('usrBlackListInsert', getToken('useNum') == this.chatItem.createNo ? this.chatItem.objectNo : this.chatItem.createNo)
				} else if (e.id == 2) { //删除好友
					this.$store.dispatch('delFriends', getToken('useNum') == this.chatItem.createNo ? this.chatItem.objectNo : this.chatItem.createNo)
				} else if (e.id == 3) { //
					this.$store.dispatch('usrBlackListRemove', getToken('useNum') == this.chatItem.createNo ? this.chatItem.objectNo : this.chatItem.createNo)
				}
			}
		}
	};
</script>

<style lang="scss">
	.chat-template-box {
		height: 100%;
		width: 100%;
		overflow: hidden;
	}
</style>
